<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:rich="http://richfaces.org/rich">
<ui:composition>

	<c:if test="${empty rotulo}">
		<c:set var="rotulo" value="${msg[campo]}" />
	</c:if>

	<c:if test="${empty ordenar}">
		<c:set var="ordenar" value="${false}" />
	</c:if>
	
	<c:if test="${empty rendered}">
		<c:set var="rendered" value="${true}" />
	</c:if>
	<c:set var="campoAux" value="${entidade}"/>
	<c:set var="indice" value="${0}"/>
	<c:set var="idAux" value="${''}"/>
	<c:forEach var="cadeia" items="${fn:split(campo,'')}" varStatus="status">
		<c:if test="${cadeia == '.'}">
			<c:set var="campoAux" value="${campoAux[fn:substring(campo,indice,status.index - 1)]}"/>
			<c:set var="idAux" value="${idAux}${fn:substring(campo,indice,status.index - 1)}"/>
			<c:set var="indice" value="${status.index}"/>
		</c:if>
		<c:if test="${status.last}">
			<c:set var="idAux" value="${idAux}${fn:substring(campo,indice,status.index)}"/>
			<c:set var="campoAux" value="${campoAux[fn:substring(campo,indice,status.index)]}"/>
		</c:if>
	</c:forEach>
	<c:if test="${ordenar}">
		<rich:column sortBy="${campoAux}" rendered="${rendered}">
			<f:facet name="header">
				<h:panelGroup>
					<a4j:loadStyle src="resource:///cssjs/template.css" />
					<h:outputText id="${idAux}Label" value="${rotulo}"/>
				</h:panelGroup>
			</f:facet>
			<h:outputText id="${idAux}Text" value="${campoAux}">
				<ui:insert/>
			</h:outputText>
		</rich:column>
	</c:if>
	<c:if test="${!ordenar}">
		<rich:column rendered="${rendered}">
			<f:facet name="header">
				<h:panelGroup>
					<a4j:loadStyle src="resource:///cssjs/template.css" />
					<h:outputText id="${idAux}Label" value="${rotulo}"/>
				</h:panelGroup>
			</f:facet>
			<h:outputText id="${idAux}Text" value="${campoAux}">
				<ui:insert/>
			</h:outputText>
		</rich:column>
	</c:if>
	
</ui:composition>
</html>